<%@page import="java.text.SimpleDateFormat"%>
<%@page import="java.text.DateFormat"%>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP '2.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

  </head>
  
  <body>
 <!-- 闰年个数 -->
    <%
    int count=0;
    for(int i=2000;i<2013;i++){
    if((i%4==0&&i%100!=0)|| i%400==0){
    count++;
    out.print(i+"\t");
    }
    }
     %>
   <br> <%=count+"个闰年"%><br>
   <!-- 当前时间 -->
   <%
   DateFormat f=new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss");
   Date d=new Date();
   String str=f.format(d);
    %><br>
    当前时间是
   <%=str %><br>
      <!-- 所有素数 -->
      <% 
   for (int i = 2; i <= 100; i++)
          {    
             int temp = (int) Math.sqrt(i);        
             if (i <= 3)
              {    
                out.print(i + " 是素数   ");       
              } 
              else 
              {  
                 for (int j = 2; j <= temp; j++) 
                 {  
                     if (i % j == 0) 
                     {    
                         break;    
                     }    
                     if (j >= temp) 
                     {    
                      out.println(i + "是素数   "); 
                      
                     }    
                  }
                 
             }
             
          }
          
     %><br>
   
 <!-- 100以内所有素数和 -->
   <%
      int sum = 0;        
      for(int i = 2; i < 100; i++){      
            boolean isPrime = true;      
            for(int j = 2; j < i; j++){  
             if(i % j == 0){
         	 isPrime = false;  
         	  break;  
     		 }      
     	 }       
           if(isPrime){       
            sum += i;      
 			}        
  	 }      
       out.println("素数和："+sum);   
    %>
  </body>
</html>
